﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Xml;

namespace GameBanChim_Version1
{
    public class StateTrailer : GameState
    {
        Video _video;
        VideoPlayer _player;
        Texture2D _videotexture;

        public override void InnitState(MyGame owner)
        {
            base.InnitState(owner);
            _video = MyGameOwner.Content.Load<Video>("test");
            _player = new VideoPlayer();
        }

        bool flag = false;

        public override void Update(GameTime gameTime)
        {
            if (_player.State == MediaState.Stopped)
            {
                flag = true;
                _player.Play(_video);
                
            }
            if (flag)
            {
                _player.IsLooped = false;
            }
            if (_player.IsDisposed)
            {
                MyGameOwner.MyGameState = new StateMenu();
                MyGameOwner.MyGameState.InnitState(MyGameOwner);
            }
            //base.Update(gameTime);
        }
        public override void Draw(GameTime gameTime, SpriteBatch sb)
        {
            if (!flag)
            {
                return;
            }
            else
            {
                if (_player.State != MediaState.Stopped)
                {
                    _videotexture = _player.GetTexture();
                }
                sb.Draw(_videotexture, new Rectangle(0, 0, 800, 600), Color.White);
            }
            //base.Draw(gameTime, sb);
        }
    }
}
